package cn.flying.data.core.processor;

import cn.flying.data.entity.config.FieldMappingConfig;

public class CompiledMapping {
    private FieldMappingConfig config;
    private String jsonPath;
    private String dbFieldName;
    private FieldMappingConfig.FieldType fieldType;
    private Integer fieldLength;
    private boolean required;
    private String defaultValue;
    private String dateFormat;
    private String targetTable;
    private int fieldOrder;

    public CompiledMapping(FieldMappingConfig config) {
        this.config = config;
//        this.jsonPath = JsonPath.compile(config.getJsonPath());
        this.jsonPath = config.getJsonPath();
        this.dbFieldName = config.getDbFieldName();
        this.fieldType = config.getFieldType();
        this.fieldLength = config.getFieldLength();
        this.required = Boolean.TRUE.equals(config.getRequired());
        this.defaultValue = config.getDefaultValue();
        this.dateFormat = config.getDateFormat();
        this.targetTable = config.getTargetTable();
        this.fieldOrder = config.getFieldOrder() != null ? config.getFieldOrder() : 0;
    }

    public FieldMappingConfig getConfig() {
        return config;
    }

    public void setConfig(FieldMappingConfig config) {
        this.config = config;
    }

    public String getJsonPath() {
        return jsonPath;
    }

    public void setJsonPath(String jsonPath) {
        this.jsonPath = jsonPath;
    }

    public String getDbFieldName() {
        return dbFieldName;
    }

    public void setDbFieldName(String dbFieldName) {
        this.dbFieldName = dbFieldName;
    }

    public FieldMappingConfig.FieldType getFieldType() {
        return fieldType;
    }

    public void setFieldType(FieldMappingConfig.FieldType fieldType) {
        this.fieldType = fieldType;
    }

    public Integer getFieldLength() {
        return fieldLength;
    }

    public void setFieldLength(Integer fieldLength) {
        this.fieldLength = fieldLength;
    }

    public boolean isRequired() {
        return required;
    }

    public void setRequired(boolean required) {
        this.required = required;
    }

    public String getDefaultValue() {
        return defaultValue;
    }

    public void setDefaultValue(String defaultValue) {
        this.defaultValue = defaultValue;
    }

    public String getDateFormat() {
        return dateFormat;
    }

    public void setDateFormat(String dateFormat) {
        this.dateFormat = dateFormat;
    }

    public String getTargetTable() {
        return targetTable;
    }

    public void setTargetTable(String targetTable) {
        this.targetTable = targetTable;
    }

    public int getFieldOrder() {
        return fieldOrder;
    }

    public void setFieldOrder(int fieldOrder) {
        this.fieldOrder = fieldOrder;
    }
}